#ifndef TLS_UTILS_H
#define TLS_UTILS_H
#include "config.h"
#include <cstdlib>
#include <cmath>

namespace tls{

  inline bool equ(const real& x,const real& y){
    return std::fabs(x-y) < eps;
  }

  inline real clamp(const real& x,const real& l=0,const real& u=1){
    if(x>u) return u;
    else if(x<l) return l;
    else return x;
  }

  inline void srand_real(int x=13){
    srand(x);
  }
  //[0,1]
  inline real rand_real(){
    return ((real)std::rand()) / RAND_MAX;
  }
}//namespace tls

#endif
